import 'package:flutter/material.dart';

/// 仪表盘页面
/// 
/// 这是一个示例仪表盘页面，用于演示路由导航
class DashboardPage extends StatelessWidget {
  /// 页面标题
  final String title;
  
  /// 构造函数
  const DashboardPage({
    Key? key,
    this.title = '控制台',
  }) : super(key: key);
  
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 页面标题
          Text(
            title,
            style: const TextStyle(
              fontSize: 24,
              fontWeight: FontWeight.bold,
            ),
          ),
          const SizedBox(height: 16),
          
          // 欢迎消息
          const Text(
            '欢迎回到Miaoyi Admin管理系统',
            style: TextStyle(
              fontSize: 16,
              color: Colors.grey,
            ),
          ),
          const SizedBox(height: 24),
          
          // 主要内容区
          Expanded(
            child: _buildContent(),
          ),
        ],
      ),
    );
  }
  
  /// 构建主要内容区
  Widget _buildContent() {
    return Center(
      child: Card(
        elevation: 3,
        child: Padding(
          padding: const EdgeInsets.all(32.0),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(
                _getPageIcon(),
                size: 64,
                color: Colors.blue,
              ),
              const SizedBox(height: 16),
              Text(
                '这是$title页面',
                style: const TextStyle(
                  fontSize: 20,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 8),
              const Text(
                '通过点击左侧导航菜单可以切换到其他页面',
                style: TextStyle(
                  fontSize: 16,
                  color: Colors.grey,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
  
  /// 根据页面标题返回对应的图标
  IconData _getPageIcon() {
    switch (title) {
      case '控制台':
        return Icons.dashboard;
      case '数据统计':
        return Icons.analytics;
      case '按钮':
        return Icons.smart_button;
      case '表单':
        return Icons.edit_document;
      case '表格':
        return Icons.table_chart;
      case '卡片':
        return Icons.style;
      case '登录':
        return Icons.login;
      case '注册':
        return Icons.app_registration;
      default:
        return Icons.web;
    }
  }
} 